package com.wyg.ep_mail.controller;

import com.wyg.ep_mail.common.uti.EmailUtil;
import com.wyg.epcommonbase.mail.MailReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: WangYongGan
 * @Date: 2022/5/14 11:00
 * @Description:
 */

@RestController
//@RequestMapping("ep-mail")
@Api(tags = "邮箱Controller")
@Slf4j
public class MailController {

    @ApiOperation("test")
    @GetMapping("test")
    public String test() {
        log.error("test");
        return "test";
    }

    @ApiOperation("发送")
    @PostMapping("send")
    public boolean send(@RequestBody MailReq req) {
        if (StringUtils.isEmpty(req.getSubject()))
            req.setSubject("金融舆情提醒");
        if (StringUtils.isEmpty(req.getText()))
            req.setText("暂无内容");
        EmailUtil.sendEmail(EmailUtil.QQ, req.getMail(), req.getSubject(), req.getText());
        return true;
    }

}
